package it.amicosmanettone.finance.stocky.adapter;

import it.amicosmanettone.finance.stocky.R;
import it.amicosmanettone.finance.stocky.util.FinanceUtil;
import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ListAdapterMain extends ArrayAdapter {

	private Context contextApp;

	public ListAdapterMain(Context context, int textViewResourceId) {
		super(context, textViewResourceId);
		contextApp = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) getContext()
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		convertView = inflater.inflate(R.layout.row_main, null);
		TextView nome = (TextView) convertView.findViewById(R.id.textViewName);
		TextView value = (TextView) convertView
				.findViewById(R.id.textViewValue);

		Typeface robotoThin = Typeface.createFromAsset(contextApp.getAssets(),
				"Roboto-Thin.ttf");
		value.setTypeface(robotoThin);
		value.refreshDrawableState();

		nome.setText(FinanceUtil.getAllPortfolio().get(position)
				.getPortfolioName());
		value.setText("("
				+ FinanceUtil.getAllPortfolio().get(position)
						.getTotalPortfolioValue()
				+ " "
				+ FinanceUtil.getAllPortfolio().get(position)
						.getCurrencyTotalPortfolioValue() + ")");
		return convertView;
	}

}